package 数组.有多少小于当前数字的数字;

import java.util.*;
import java.util.stream.Collectors;

/**
 * @author: wh(1835734390 @ qq.com)
 * @date: 2023/2/22 17:03
 * @description:
 * @version:
 */
public class Solution {
    public static void main(String[] args) {
        int[] array = {8,1,2,2,3};
        int[] ints = smallerNumbersThanCurrent(array);
        for (Integer num:ints) {
            System.out.println(num);
        }
    }


    public static int[] smallerNumbersThanCurrent(int[] nums) {
        int n = nums.length;
        int[] ret = new int[n];
        for (int i = 0; i < n; i++) {
            int cnt = 0;
            for (int j = 0; j < n; j++) {
                if (nums[j] < nums[i]) {
                    cnt++;
                }
            }
            ret[i] = cnt;
        }
        return ret;
    }
}
